from django.db import models
from django.db.models import get_model
from django.db import connection

import settings

class Tag(models.Model):
    name = models.CharField(max_length=100, unique=True)
    slug = models.SlugField(unique=True)    
    #dynamically create M2M fields for this model
    for key, value in settings.TAGGABLE_MODELS.iteritems():
        codestring = ""+key+" = models.ManyToManyField('"+value+"', blank=True, null=True)"
        exec(codestring)
    
    def __unicode__(self):
        return self.name
